package datasource.image;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

import com.aliasi.cluster.KMeansClusterer;
import com.aliasi.util.FeatureExtractor;

public class TimeClustering {
	public static void cluster(ArrayList<ImageObj> objs, int numberOfClusters, int numberIteration) {
		Set<ImageObj> imageSet = new HashSet<ImageObj>();
		for (ImageObj obj : objs) {
			if (obj.time != null) {
				imageSet.add(obj);
			}
		}
		FeatureExtractor<ImageObj> fExtractor = new TimeFeatureExtractor<ImageObj>();
		KMeansClusterer<ImageObj> clustering = new KMeansClusterer<ImageObj>(
				fExtractor, numberOfClusters, numberIteration, true, 0);
		Set<Set<ImageObj>> clusters = clustering.cluster(imageSet);
		int count = 0;
		for (Set<ImageObj> cluster : clusters) {
			count++;
			for (ImageObj obj : cluster) {
				obj.timeClusterID = count;
			}
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
